package com.googlecode.olabs.common.desktop;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;

/**
 * Creates a JFrame, and adds itself as a listener, so when someone closes it,
 * the program will end.
 */
public class JFrameClose extends JFrame implements WindowListener {

	private static final long serialVersionUID = 1L;

	public JFrameClose() {
		super();
		addWindowListener(this);
	}

	public JFrameClose(String title) {
		super(title);
		addWindowListener(this);
	}

	public void windowClosed(WindowEvent event) {
	}

	public void windowDeiconified(WindowEvent event) {
	}

	public void windowIconified(WindowEvent event) {
	}

	public void windowActivated(WindowEvent event) {
	}

	public void windowDeactivated(WindowEvent event) {
	}

	public void windowOpened(WindowEvent event) {
	}

	public void windowClosing(WindowEvent event) {
		// dispose of the JFrame object
		dispose();
		// terminate the program
		System.exit(0);
	}
}